package com.czk.topic.send;

import com.czk.utils.RabbitmqUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/1/2 22:27
 */
public class Provider {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection czkConnection = RabbitmqUtils.getCzkConnection();
        Channel channel = czkConnection.createChannel();
        // 声明交换机
        channel.exchangeDeclare("topics", "topic");
        // 发布消息
        String routing_key = "user.save";
        channel.basicPublish("topics", routing_key, null, "这是topic模式".getBytes());
        RabbitmqUtils.closeConnection(channel, czkConnection);
    }
}
